package org.bigtree.example.controller;

import lombok.RequiredArgsConstructor;
import org.bigtree.example.common.webapi.PageResult;
import org.bigtree.example.model.form.EmployForm;
import org.bigtree.example.model.form.EmploySearchForm;
import org.bigtree.example.model.vo.EmployVo;
import org.bigtree.example.service.IEmployService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author bigTree
 * @since 2025/4/26
 */
@RestController
@RequestMapping("/employ")
@RequiredArgsConstructor
public class EmployController {
    private final IEmployService employService;


    @PostMapping
    public EmployVo create(@Validated @RequestBody EmployForm form) {
        return employService.create(form);
    }


    @PutMapping("/{id}")
    public EmployVo edit(@PathVariable Long id, @Validated @RequestBody EmployForm form) {
        return employService.edit(id, form);
    }


    @DeleteMapping("/{id}")
    public void remove(@PathVariable Long id) {
        employService.remove(id);
    }


    @GetMapping
    public PageResult<EmployVo> all(EmploySearchForm form) {
        return employService.all(form);
    }


    @GetMapping("/{id}")
    public EmployVo detail(@PathVariable Long id) {
        System.out.println(id);
        return employService.detail(id);
    }

}
